"use strict";(self.webpackChunkpromptmanager=self.webpackChunkpromptmanager||[]).push([[2613],{12705:function(e,n,t){t.d(n,{$5:function(){return j},C_:function(){return R},DK:function(){return T},Dg:function(){return B},Hn:function(){return y},K4:function(){return w},MC:function(){return E},NM:function(){return V},TF:function(){return D},YL:function(){return k},c5:function(){return N},e7:function(){return J},eH:function(){return m},gZ:function(){return x},iB:function(){return b},jl:function(){return h},lo:function(){return F},nC:function(){return O},pQ:function(){return S},r1:function(){return v},rc:function(){return C},v:function(){return Z},ye:function(){return P}});var r=t(4942),a=t(1413),u=t(74165),i=t(15861),o=t(56030),c=t(7077),s=(0,o.nZ)({key:"apiProvidersFetchSelector",get:function(){var e=(0,i.Z)((0,u.Z)().mark((function e(){var n;return(0,u.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,(0,c.o)().get("/api/apiproviders");case 3:return n=e.sent,e.abrupt("return",n.data);case 7:return e.prev=7,e.t0=e.catch(0),e.abrupt("return",[]);case 10:case"end":return e.stop()}}),e,null,[[0,7]])})));return function(){return e.apply(this,arguments)}}()}),l=(0,o.nZ)({key:"apiBackendsFetchSelector",get:function(){var e=(0,i.Z)((0,u.Z)().mark((function e(){var n;return(0,u.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,(0,c.o)().get("/api/apibackends");case 3:return n=e.sent,e.abrupt("return",n.data);case 7:return e.prev=7,e.t0=e.catch(0),e.abrupt("return",[]);case 10:case"end":return e.stop()}}),e,null,[[0,7]])})));return function(){return e.apply(this,arguments)}}()}),d=(0,o.nZ)({key:"endpointsFetchSelector",get:function(){var e=(0,i.Z)((0,u.Z)().mark((function e(){var n;return(0,u.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,(0,c.o)().get("/api/endpoints");case 3:return n=e.sent,e.abrupt("return",n.data);case 7:return e.prev=7,e.t0=e.catch(0),e.abrupt("return",[]);case 10:case"end":return e.stop()}}),e,null,[[0,7]])})));return function(){return e.apply(this,arguments)}}()}),p=(0,o.nZ)({key:"dataSourcesFetchSelector",get:function(){var e=(0,i.Z)((0,u.Z)().mark((function e(){var n;return(0,u.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,(0,c.o)().get("/api/datasources");case 3:return n=e.sent,e.abrupt("return",n.data);case 7:return e.prev=7,e.t0=e.catch(0),e.abrupt("return",[]);case 10:case"end":return e.stop()}}),e,null,[[0,7]])})));return function(){return e.apply(this,arguments)}}()}),f=(0,o.nZ)({key:"dataSourceTypesFetchSelector",get:function(){var e=(0,i.Z)((0,u.Z)().mark((function e(){var n;return(0,u.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,(0,c.o)().get("/api/datasource_types");case 3:return n=e.sent,e.abrupt("return",n.data);case 7:return e.prev=7,e.t0=e.catch(0),e.abrupt("return",[]);case 10:case"end":return e.stop()}}),e,null,[[0,7]])})));return function(){return e.apply(this,arguments)}}()}),v=(0,o.cn)({key:"apiProviders",default:s}),Z=(0,o.nZ)({key:"apiProviderDropdownList",get:function(){var e=(0,i.Z)((0,u.Z)().mark((function e(n){var t,r;return(0,u.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=n.get,e.next=3,t(v);case 3:return r=e.sent,e.abrupt("return",r.map((function(e){return{label:e.name,value:e.name}})));case 5:case"end":return e.stop()}}),e)})));return function(n){return e.apply(this,arguments)}}()}),h=(0,o.cn)({key:"apiProviderSelected",default:null}),k=(0,o.cn)({key:"apiBackends",default:l}),y=(0,o.nZ)({key:"apiBackendDropdownList",get:function(e){var n=e.get,t=n(k),r=n(J);return t.filter((function(e){return-1===((null===r||void 0===r?void 0:r.disabled_api_backends)||[]).indexOf(e.id)})).map((function(e){return{label:e.name,value:e.id,provider:e.api_provider.name}}))}}),x=(0,o.cn)({key:"apiBackendSelected",default:null}),g=(0,o.cn)({key:"endpoints",default:d}),m=((0,o.nZ)({key:"endpointDropdownList",get:function(e){var n=(0,e.get)(g);return n.filter((function(e){return 0===e.version&&!e.draft})).sort((function(e,n){return e.created_on<n.created_on?1:-1})).map((function(e){return{label:"".concat(e.api_backend.api_provider.name," \xbb ").concat(e.api_backend.name," \xbb ").concat(e.name),uuid:e.uuid,options:n.filter((function(n){return n.parent_uuid===e.uuid})).map((function(n){return{label:"".concat(n.version,": ").concat(n.description),value:"".concat(n.parent_uuid,":").concat(n.version),version:n.version,backend:e.api_backend.name,provider:e.api_backend.api_provider.name,is_live:n.is_live,uuid:n.uuid}}))}}))}}),(0,o.cn)({key:"endpointSelected",default:null})),b=(0,o.nZ)({key:"endpointTableData",get:function(e){for(var n=(0,e.get)(g).filter((function(e){return!e.draft})).sort((function(e,n){return e.created_on<n.created_on?1:-1})),t=n.filter((function(e){return 0===e.version})).reduce((function(e,n){var t=(0,r.Z)({},n.uuid,(0,a.Z)((0,a.Z)({},n),{},{versions:[],key:n.uuid}));return(0,a.Z)((0,a.Z)({},e),t)}),{}),u=n.filter((function(e){return 0!==e.version})),i=0;i<u.length;i++)u[i].parent_uuid in t&&t[u[i].parent_uuid].versions.push((0,a.Z)((0,a.Z)({},u[i]),{},{key:u[i].uuid}));return Object.values(t)}}),w=((0,o.cn)({key:"endpointVersions",default:[]}),(0,o.cn)({key:"endpointConfigValue",default:{}})),S=(0,o.cn)({key:"promptValues",default:{}}),j=(0,o.cn)({key:"inputValue",default:{}}),_=((0,o.cn)({key:"saveEndpointModalVisible",default:!1}),(0,o.cn)({key:"saveEndpointVersionModalVisible",default:!1}),(0,o.cn)({key:"shareEndpointModalVisible",default:!1}),(0,o.cn)({key:"endpointShareCodeValue",default:null}),(0,o.nZ)({key:"profileFetchSelector",get:function(){var e=(0,i.Z)((0,u.Z)().mark((function e(){var n;return(0,u.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,(0,c.o)().get("/api/profiles/me");case 3:return n=e.sent,e.abrupt("return",n.data);case 7:return e.prev=7,e.t0=e.catch(0),e.abrupt("return",null);case 10:case"end":return e.stop()}}),e,null,[[0,7]])})));return function(){return e.apply(this,arguments)}}()})),C=(0,o.cn)({key:"profileValue",default:_}),O=(0,o.nZ)({key:"isLoggedIn",get:function(e){return null!==(0,e.get)(C)}}),I=(0,o.cn)({key:"promptHubState",default:[]}),V=((0,o.nZ)({key:"promptHubList",get:function(e){return(0,e.get)(I)}}),(0,o.cn)({key:"dataSourcesState",default:p})),N=(0,o.nZ)({key:"orgDataSourcesState",get:function(){var e=(0,i.Z)((0,u.Z)().mark((function e(n){var t,r;return(0,u.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=n.get,e.prev=1,t(B).IS_ORGANIZATION_MEMBER){e.next=5;break}return e.abrupt("return",[]);case 5:return e.next=7,(0,c.o)().get("/api/org/datasources");case 7:return r=e.sent,e.abrupt("return",r.data);case 11:return e.prev=11,e.t0=e.catch(1),e.abrupt("return",[]);case 14:case"end":return e.stop()}}),e,null,[[1,11]])})));return function(n){return e.apply(this,arguments)}}()}),D=(0,o.cn)({key:"dataSourceTypesState",default:f}),E=(0,o.cn)({key:"dataSourceEntriesState",default:[]}),T=(0,o.cn)({key:"orgDataSourceEntriesState",default:[]}),P=(0,o.nZ)({key:"dataSourceEntriesTableData",get:function(e){var n=e.get,t=n(E),r=n(B);t=t.map((function(e){return(0,a.Z)({isUserOwned:!0},e)}));var u=r.IS_ORGANIZATION_MEMBER?n(T):[];u=u.map((function(e){return(0,a.Z)({isUserOwned:!1},e)}));var i=n(V),o=(i=i.map((function(e){return(0,a.Z)({isUserOwned:!0},e)}))).map((function(e){return e.uuid})),c=r.IS_ORGANIZATION_MEMBER?n(N):[];c=(c=c.map((function(e){return(0,a.Z)({isUserOwned:!1},e)}))).filter((function(e){return!o.includes(e.uuid)}));for(var s=[],l={},d={},p=0;p<t.length;p++)t[p].datasource.uuid in l?l[t[p].datasource.uuid].push(t[p]):l[t[p].datasource.uuid]=[t[p]];for(var f=0;f<u.length;f++)u[f].datasource.uuid in d?d[u[f].datasource.uuid].push(u[f]):d[u[f].datasource.uuid]=[u[f]];for(var v=0;v<i.length;v++)s.push((0,a.Z)((0,a.Z)({},i[v]),{data_source_entries:l[i[v].uuid]||[]}));for(var Z=0;Z<c.length;Z++)s.push((0,a.Z)((0,a.Z)({},c[Z]),{data_source_entries:d[c[Z].uuid]||[]}));return s}}),F=(0,o.cn)({key:"isMobileState",default:window.innerWidth<768}),M=((0,o.cn)({key:"appTemplateState",default:null}),(0,o.cn)({key:"appDebugState",default:{}}),(0,o.nZ)({key:"appsFetchSelector",get:function(){var e=(0,i.Z)((0,u.Z)().mark((function e(){var n;return(0,u.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,(0,c.o)().get("/api/apps");case 3:return n=e.sent,e.abrupt("return",n.data);case 7:return e.prev=7,e.t0=e.catch(0),e.abrupt("return",[]);case 10:case"end":return e.stop()}}),e,null,[[0,7]])})));return function(){return e.apply(this,arguments)}}()})),R=(0,o.cn)({key:"appsState",default:M}),A=(0,o.nZ)({key:"profileFlagsFetchSelector",get:function(){var e=(0,i.Z)((0,u.Z)().mark((function e(){var n;return(0,u.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,(0,c.o)().get("/api/profiles/me/flags");case 3:return n=e.sent,e.abrupt("return",n.data);case 7:return e.prev=7,e.t0=e.catch(0),e.abrupt("return",{});case 10:case"end":return e.stop()}}),e,null,[[0,7]])})));return function(){return e.apply(this,arguments)}}()}),B=(0,o.cn)({key:"profileFlagsState",default:A}),z=(0,o.nZ)({key:"organizationFetchSelector",get:function(){var e=(0,i.Z)((0,u.Z)().mark((function e(){var n;return(0,u.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,(0,c.o)().get("/api/org");case 3:return n=e.sent,e.abrupt("return",n.data);case 7:return e.prev=7,e.t0=e.catch(0),e.abrupt("return",null);case 10:case"end":return e.stop()}}),e,null,[[0,7]])})));return function(){return e.apply(this,arguments)}}()}),J=(0,o.cn)({key:"organizationState",default:z})},7077:function(e,n,t){t.d(n,{o:function(){return u}});var r=t(11912),a=t(58518),u=function(){var e=r.Z.create({xsrfCookieName:"csrftoken",xsrfHeaderName:"X-CSRFToken"});return e.interceptors.response.use((function(e){return e}),(function(e){return window.location.pathname.startsWith("/s/")||window.location.pathname.startsWith("/hub")||window.location.pathname.startsWith("/app/")||401!==e.response.status&&403!==e.response.status||(window.location.href="/login"),(0,a.yv)("Error Occurred",{variant:"error"}),Promise.reject(e)})),e}},12613:function(e,n,t){t.r(n),t.d(n,{default:function(){return S}});var r=t(93433),a=t(29439),u=t(72791),i=t(56030),o=t(57689),c=t(17828),s=t(66106),l=t(30914),d=t(80458),p=t(49389),f=t(45863),v=t(49428),Z=t(83099),h=t(87309),k=t(55768),y=t(12705),x=t(29040),g=t(7077),m=t(80184);function b(e){var n=e.visible,t=e.versions,r=e.onCancel,i=t[0],o=t[1],v=(0,u.useState)({config:i.config,input:i.input}),Z=(0,a.Z)(v,2),h=Z[0],k=Z[1],y=(0,u.useState)({config:o.config,input:o.input}),g=(0,a.Z)(y,2),b=g[0],w=g[1],S=(0,u.useState)(i.version),j=(0,a.Z)(S,2),_=j[0],C=j[1],O=(0,u.useState)(o.version),I=(0,a.Z)(O,2),V=I[0],N=I[1];return(0,m.jsxs)(c.Z,{onClose:r,open:n,title:"Compare ".concat(t[0].name," Versions"),placement:"left",size:"large",width:"100%",children:[(0,m.jsxs)(s.Z,{children:[(0,m.jsxs)(l.Z,{span:12,children:[(0,m.jsx)(s.Z,{children:(0,m.jsx)(d.Z,{defaultValue:t[0].version,value:_,style:{width:120},onChange:function(e){C(e);var n=t.find((function(n){return n.version===e}));k({config:n.config,input:n.input})},options:t.map((function(e){return{label:e.version,value:e.version}}))})}),(0,m.jsx)(s.Z,{children:(0,m.jsx)(p.Z.TextArea,{autoSize:{minRows:6,maxRows:10},disabled:!0,value:h?JSON.stringify(h):""})})]}),(0,m.jsxs)(l.Z,{span:12,children:[(0,m.jsx)(s.Z,{children:(0,m.jsx)(d.Z,{defaultValue:t[1].version,value:V,style:{width:120},onChange:function(e){N(e);var n=t.find((function(n){return n.version===e}));w({config:n.config,input:n.input})},options:t.map((function(e){return{label:e.version,value:e.version}}))})}),(0,m.jsx)(s.Z,{children:(0,m.jsx)(p.Z.TextArea,{disabled:!0,value:b?JSON.stringify(b):"",autoSize:{minRows:6,maxRows:10}})})]})]}),h&&b&&(0,m.jsx)(s.Z,{children:(0,m.jsxs)(l.Z,{span:24,children:[(0,m.jsx)(s.Z,{children:(0,m.jsx)(f.Z.Title,{level:4,children:"Configuration Diff"})}),(0,m.jsx)(s.Z,{children:(0,m.jsx)(x.ZP,{oldValue:JSON.stringify(h.config),newValue:JSON.stringify(b.config),showDiffOnly:!0})}),(0,m.jsx)(s.Z,{children:(0,m.jsx)(f.Z.Title,{level:4,children:"Input Diff"})}),(0,m.jsx)(s.Z,{children:(0,m.jsx)(x.ZP,{oldValue:JSON.stringify(h.input),newValue:JSON.stringify(b.input),showDiffOnly:!0})})]})})]})}function w(e){var n=e.visible,t=e.onCancel,r=e.onConfirm;return(0,m.jsx)(v.Z,{open:n,onCancel:t,onOk:r,children:(0,m.jsx)(f.Z.Title,{level:4,children:"Are you sure you want to delete this endpoint?"})})}function S(){var e=(0,u.useState)(!1),n=(0,a.Z)(e,2),t=n[0],c=n[1],d=(0,u.useState)(!1),p=(0,a.Z)(d,2),f=p[0],v=p[1],x=(0,u.useState)(null),S=(0,a.Z)(x,2),j=S[0],_=S[1],C=(0,i.sJ)(y.iB),O=(0,u.useState)([]),I=(0,a.Z)(O,2),V=I[0],N=I[1],D=(0,o.s0)();var E=[{title:"Name",dataIndex:"name",key:"name"},{title:"Provider",dataIndex:"api_backend",key:"provider",render:function(e){return(0,m.jsx)("div",{children:e.api_provider.name})}},{title:"Backend",dataIndex:"api_backend",key:"backend",render:function(e){return(0,m.jsx)("div",{children:e.api_endpoint})}},{title:"Versions",dataIndex:"versions",key:"versions",render:function(e){return(0,m.jsx)(Z.Z,{size:"middle",children:(0,m.jsx)(h.ZP,{style:{color:"#1677ff"},type:"text",onClick:function(){},children:e.length+1})})}},{title:"Actions",key:"action",render:function(e){var n=[e].concat((0,r.Z)(e.versions));return(0,m.jsxs)(Z.Z,{size:"middle",children:[(0,m.jsx)(h.ZP,{style:{color:"#1677ff"},type:"text",onClick:function(){D("/")},children:"Edit"}),(0,m.jsx)(h.ZP,{style:{color:"#1677ff"},type:"text",onClick:function(){v(!0),_(e)},children:"Delete"}),e.versions.length>1&&(0,m.jsx)(h.ZP,{style:{color:"#1677ff"},type:"text",onClick:function(){N(n),c(!0)},children:"Compare"})]})}}];return(0,m.jsxs)("div",{id:"endpoint-page",children:[(0,m.jsx)(s.Z,{children:(0,m.jsx)(l.Z,{span:24,children:(0,m.jsx)(k.Z,{dataSource:C,columns:E,expandable:{expandedRowRender:function(e){var n=[{title:"Version",dataIndex:"version"},{title:"Change Message",dataIndex:"description"},{title:"Is App Endpoint",dataIndex:"is_app",render:function(e){return(0,m.jsx)("div",{children:e?"Yes":"No"})}},{title:"Is Live",dataIndex:"is_live",render:function(e){return(0,m.jsx)("div",{children:e?"Yes":"No"})}},{title:"Action",render:function(e){return(0,m.jsxs)(Z.Z,{size:"middle",children:[(0,m.jsx)(h.ZP,{style:{color:"#1677ff"},type:"text",onClick:function(){},children:"View"}),(0,m.jsx)(h.ZP,{style:{color:"#1677ff"},type:"text",onClick:function(){v(!0),_(e)},children:"Delete"})]})}}];return(0,m.jsx)(k.Z,{dataSource:e.versions,columns:n})}}})})}),t&&(0,m.jsx)(b,{visible:t,versions:V,onCancel:function(){c(!1),N([])}}),f&&(0,m.jsx)(w,{visible:f,onConfirm:function(){j&&(0,g.o)().delete("/api/endpoints/".concat(j.uuid)).then((function(e){})).finally((function(){v(!1),_(null),window.location.reload()}))},onCancel:function(){v(!1),_(null)}})]})}}}]);
//# sourceMappingURL=2613.41a2229e.chunk.js.map